<template>
  <div>
    <p v-if="token">登录成功，正在跳转...</p>
    <p v-else>登录失败或未获取到token</p>
  </div>
</template>

<script setup>
import { onMounted, ref } from 'vue'
import { useRouter, useRoute } from 'vue-router'
import { useUserStore } from '../stores/user'

const router = useRouter()
const route = useRoute()
const userStore = useUserStore()
const token = ref('')

onMounted(() => {
  const urlToken = route.query.token
  if (urlToken) {
    token.value = urlToken
    userStore.setToken(urlToken) // 存到 pinia 和 localStorage
    router.push('/dynamicmenu') // 跳转首页
  }else {
    router.replace('/login') // 跳转登录页
  }
})
</script> 